/*
 * File:    OutputCompare.c
 * Project:	HobbyPilotFirmware (HPF)
 * Author:  Wouter van Verre
 *
 * Created on March 17, 2011, 2:30 PM
 */

#include "Header.h"

void initOC(void)
{
#if (NUM_CHAN_OUT > 0)
	OC1CONbits.OCSIDL = 1; 		// Stop when the microcontroller enters idle mode
	OC1CONbits.OCTSEL = 0;		// Select Timer2 as clock source
	OC1CONbits.OCM = 0b110;		// Select PWM mode without fault protection

	OC1RS = 2764;
#endif

#if (NUM_CHAN_OUT > 1)
	OC2CONbits.OCSIDL = 1; 		// Stop when the microcontroller enters idle mode
	OC2CONbits.OCTSEL = 0;		// Select Timer2 as clock source
	OC2CONbits.OCM = 0b110;		// Select PWM mode without fault protection

	OC2RS = 2764;
#endif

#if (NUM_CHAN_OUT > 2)
	OC3CONbits.OCSIDL = 1; 		// Stop when the microcontroller enters idle mode
	OC3CONbits.OCTSEL = 0;		// Select Timer2 as clock source
	OC3CONbits.OCM = 0b110;		// Select PWM mode without fault protection

	OC3RS = 2764;
#endif

#if (NUM_CHAN_OUT > 3)
	OC4CONbits.OCSIDL = 1; 		// Stop when the microcontroller enters idle mode
	OC4CONbits.OCTSEL = 0;		// Select Timer2 as clock source
	OC4CONbits.OCM = 0b110;		// Select PWM mode without fault protection

	OC4RS = 2764;
#endif
}
